package com.hk.card;

import java.util.ArrayList;

import javax.swing.ImageIcon;
import javax.swing.JLabel;

public abstract class TakenCardSuper {
	protected ArrayList<TakenCard> cardList;
	protected int CardCount = 0;

	public TakenCardSuper() {
		cardList = new ArrayList<TakenCard>();
	}
	public void AddCard() {
		cardList.add(new TakenCard());
	}
	//set
	public abstract void SetBounds();
	public void SetCard() {
		CardCase cc = CardCase.getCardCase();
		int number = cc.getCardNum();
		cardList.get(CardCount).SetCard(cc.getCard(), number);
		SetBounds();
	}
	//get
	public ArrayList<TakenCard> getList() {
		return cardList;
	}
	public JLabel getLabel(int count) {
		return cardList.get(count).getjLabel();
	}
	public ImageIcon getIcon(int count) {
		return (ImageIcon) cardList.get(count).getjLabel().getIcon();
	}
	public int getNumber(int count) {
		return cardList.get(count).getNumber();
	}
	public int getSum() {
		int sumA1 = 0;
		int sumA11 = 0;

		for (int i = 0; i < CardCount; i++) {
			if (cardList.get(i).getNumber()==1) {
				sumA11 += cardList.get(i).getNumber() + 10;
			} else {
				sumA11 += cardList.get(i).getNumber();
			}
			sumA1 += cardList.get(i).getNumber();
		}

		if (sumA11<=21) {
			return sumA11;
		} else {
			return sumA1;
		}
	}
	public void ReSet() {
		CardCount = 0;
		if(cardList!=null){
			for (int i = 0; i < cardList.size(); i++) {
				cardList.get(i).SetCard(new ImageIcon("./"), 0);
			}
		}
	}
}
